package com.bsi.login.validate.entity;

import com.bsi.core.validate.spring.group.Delete;
import com.bsi.core.validate.spring.group.Insert;
import com.bsi.core.validate.spring.group.Select;
import com.bsi.core.validate.spring.group.Update;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.validation.GroupSequence;
import javax.validation.constraints.*;
import java.math.BigDecimal;

/**
 * @ClassName Product
 * @Author LiuSong
 * @Date 2020/7/27 14:12
 * @Version 1.0
 * @Description
 */
@Data
@Getter
@Setter
public class Product {
    @NotNull(groups = {Insert.class}, message = "商品名不能为空")
    String name;

    @DecimalMin(groups = {Insert.class}, message = "价格必须大于0", value = "0")
    @DecimalMax(groups = {Insert.class}, message = "价格最大为1万元", value = "10000")
    BigDecimal money;

    @NotNull(groups = {Insert.class, Update.class}, message = "可售台数不能为空")
    @Min(groups = {Insert.class}, message = "可售台数必须大于0", value = 0)
    @Max(groups = {Insert.class}, message = "可售台数少于1000", value = 1000)
    Integer number;

    @Email(groups = Insert.class, message = "邮箱格式不正确,请重新输入")
    @NotNull(groups = {Insert.class, Update.class}, message = "可售台数不能为空")
    String email;

    @Pattern(groups = {Insert.class}, regexp = "^1(3|4|5|7|8)\\d{9}$",message = "手机号不匹配")
    String telephone;
}
